package com.nothingboard.common.data;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class NtbMap {
	
	private Map<Object,Object> data;
	
	public NtbMap(){
		data = new HashMap<Object,Object>();
	}
	
	@SuppressWarnings("unchecked")
	public List<Object> getList(Object key){
		List<Object> value = null;
		try{
			value = (List<Object>)data.get(key);
		}catch(Exception e){
			
		}
		return value;
	}
	
	public String getString(String key){
		return getString(key,"");
	}
	
	public String getString(Object key, String defaultValue){
		String value = "";
		try{
			value = String.valueOf(data.get(key));
		}catch(Exception e){
			return defaultValue;
		}
		return value;
	}
	
	public int getInt(Object key){
		return getInt(key, 0);
	}
	
	public int getInt(Object key, int defaultValue){
		int value;
		try{
			value = ((Integer)data.get(key)).intValue();
		}catch(Exception e){
			return defaultValue;
		}
		return value;
	}
	
	public long getLong(Object key){
		return getLong(key, 0);
	}
	
	public long getLong(Object key, long defaultValue){
		long value;
		try{
			value = ((Long)data.get(key)).longValue();
		}catch(Exception e){
			return defaultValue;
		}
		return value;
	}

}
